package com.itc.bi.kafaka;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itc.bi.constant.KafkaConstant;
import com.itc.bi.dto.kafka.DataSetDTO;
import com.itc.bi.entity.DataProcessEntity;
import com.itc.bi.service.DataSynApiService;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @program: itc-airport-cloud
 * @description: 监听数据同步
 * @author: songxiude
 * @create: 2024-07-05 09:59
 **/
@Slf4j
@Component
public class DataSynKafkaListenter {

    @Autowired
    private DataSynApiService dataSynApiService;

    /**
     * 单次执行
     * @param record
     */
    @KafkaListener(groupId = "bi_datasyn",topics = KafkaConstant.DATA_SYN_ACCEPT)
    public void dataSynListener(ConsumerRecord record){
        String message = (String) record.value();
        JSONObject jsonObject = JSONObject.parseObject(message, JSONObject.class);
        log.info("执行数据同步内容："+message);
        //System.out.println("kafka推消息");
        //异步执行
        //dataSynApiService.startDataSyn(jsonObject);
        //System.out.println(jsonObject.getLong("tableId"));

    }
}
